﻿/* tslint:disable:jsdoc-format max-line-length */
// warning: Generated code! Do not change!
module App.Servises {
	"use strict";
	export class AjaxHelper {
		private $http: angular.IHttpService;

		constructor(public baseUrl: string) {
			this.$http = angular.injector(["ng"]).get("$http");
			if (baseUrl.match(/\/$/)) {
				baseUrl += "/";
			}
		}

		request<T>(url: string, httpVerb: string, data?: any): angular.IPromise<T> {
			var config: ng.IRequestConfig = {
				url: this.baseUrl + url,
				cache: false,
				method: httpVerb
			};

			if (data) {
				config.data = data;
			}
			return this.$http(config).then((response: angular.IHttpPromiseCallbackArg<{}>) => {
				return response.data;
			});
		}
	}
}